#ifndef FND_ANIM_ACTOR_HPP
#define FND_ANIM_ACTOR_HPP
#include "tile_actor.hpp"
#include "indexresource.hpp"
namespace FndGame2D {
  class anim_actor : public quad_actor {
  public:
    anim_actor(const std::string& name = std::string(), int draw_level = 0,
	       const mover::position_type& p = mover::position_type(),
	       float angle = 0.0f) ;
  private:
    index_resource_manager<sf::IntRect> m_rects_mgr ;
    std::string m_current_anim_name ;
    float m_anim_speed ;
    bool m_anim_looped ;
    size_t m_current_anim_index ;
    float m_current_anim_time ;
    bool handle_set_anim_loop(const normal_thinker_message_type& msg) ;
    bool handle_set_anim_speed(const normal_thinker_message_type& msg) ;
    void update_anim(float) ;
    void set_current_rect() ;
  protected:
    void set_anim_speed(float speed) {m_anim_speed = speed ;}
    void set_anim_loop(bool looped) {m_anim_looped = looped;}
  public:
    static const std::string SET_ANIM_LOOP ;
    static const std::string SET_ANIM_SPEED ;
    static const std::string HAS_ANIM ;
    int push_rect(const sf::IntRect& rect) {
      m_rects_mgr.add_value(rect) ;
      return m_rects_mgr.value_number() ;
    }
    float anim_speed()const {return m_anim_speed ;}
    bool is_anim_looped()const {return m_anim_looped ;}
    void create_anim(const std::string& anim_name) {m_rects_mgr.add_index(anim_name) ;}
    void set_anim(const std::string& anim_name) ;
    void push_anim_index(const std::string& anim_name, std::size_t index) {m_rects_mgr.add_index(anim_name,index) ;}
    /*
      bool change_anim_index(const std::string& anim_name, 
      std::size_t old_index,
      std::size_t new_index) ;
    */
    const std::string& current_anim_name() const {return m_current_anim_name ;}
    void push_anim_index(std::size_t index) {
      push_anim_index(m_current_anim_name, index) ;
    }
    /*
      bool change_anim_index(std::size_t old_index,
      std::size_t new_index) {
      return change_anim_index(m_current_anim_name, old_index, new_index) ;
      }
    */
  } ;

} ;
#endif
